<?php
require_once 'config/config.php';
require_once 'lib/member.php';
require_once 'lib/user.php';
require_once 'lib/kelas.php';
require_once 'lib/produk.php';

$config=new config();
$config->connect();


if(ISSET($_GET['alamat'])){
//echo $_GET['alamat'];
//echo "3";
$Member_Dao=new Member_Dao();
$data=$Member_Dao->get_alamat($_GET['alamat']);
}


$Kelas_Dao=new Kelas_Dao();
$kelas=$Kelas_Dao->get_all();

//echo $_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'];

?>
<?php include("header.php") ?>
<?php include("menu_kiri.php") ?>
<script>
function validasi(){
	var x = document.form1.alamat.value;
	if (x==""){
		alert('Isikan kata kunci terlebih dahulu!');
		return false;
	}
}
</script>    

<div id="body">
<div class="topbox">   
				  	
<form name="form1" method="get" action="cari_hotel.php" >
Kata Kunci: <input type="text" name="alamat" value="<?php if(ISSET($_GET['alamat'])) {echo $_GET['alamat']; } ?>" placeholder="alamat">
<input type="submit" value="cari" onclick="return validasi();">
<form>	
</div>			  
<div class="topbox">
<?php

if(isset($_GET['alamat'])){
	$i=1;
	foreach($data as $member){
	echo "<div class=\"leftbox2\">"; 
	
	echo "<table border=0 cellspacing=0 cellpadding=3>";
	
	$User_Dao=new User_Dao();
	$user=$User_Dao->get_id($member->id);
	//echo $member->id;
	$Kelas_Dao=new Kelas_Dao();
	$kelas=$Kelas_Dao->get_id($member->id_kelas);
	
	$Produk_Dao=new Produk_Dao();
	$minprice=$Produk_Dao->get_minprice($member->id);
	$maxprice=$Produk_Dao->get_maxprice($member->id);
	
	
	echo "<tr>";
		echo "<td>";
			if($member->foto_member!=""){
			echo "<a href=\"detil_hotel.php?id=$member->id\"><image src=\"member/images/hotel/$member->foto_member\" width=\"160\" height=\"141\"></a>";
			} else { echo "<image src=\"images/no_image.jpg\" width=\"160\" height=\"141\">";}
			echo "</td>";
	
		echo "<td class=\"topleft\">";
			echo "<p><b><a href=\"detil_hotel.php?id=$member->id\">Hotel ".ucwords($member->nama)."</a> , ".ucwords($kelas->kelas)."</b></p>";
			echo "<p>Kisaran harga: Rp".number_format($minprice, 2, '.', ',')." - "."Rp".number_format($maxprice, 2, '.', ',')."</p>";
			echo "<p>Email: ".ucwords($user->email)."</p>";
			echo "<p>Alamat: ".$member->alamat."</p>";
			echo "<p>no_telp: ".$member->no_telp."</p>";
			echo "<p>Fasilitas: ".$member->fasilitas_umum."</p>";
		echo "</td>";
	echo "</tr>";

 $i++;
 echo "</table>";
 echo "</div>";
 }
 }?> 

</div> 
</div>
          
         <div class="clear"></div>
         <?php include("footer.php") ?>
		